package org.metasketch.simulator.tools;

import java.util.HashMap;
import java.util.Map;

public class Registry {

	Map<String, Object> aliases = new HashMap<String, Object>();

	public void register(String alias, Object object) throws Exception {
		if (alias.contains(" "))
			throw new Exception("Alias \"" + alias
					+ "\" can't contain any space chars !!!! " + object);

		Object old = aliases.get(alias);
		if (old != null)
			throw new Exception("Alias \"" + alias
					+ "\" already has been registered for previous object "
					+ old + " . Current registry attempt for object " + object);

		aliases.put(alias, object);

	}

	public Object get(String alias) {
		return aliases.get(alias);
	}

	public Map<String, Object> getAliases() {
		return aliases;
	}

	public void setAliases(Map<String, Object> aliases) {
		this.aliases = aliases;
	}

}
